package com.itheima.health.controller;

import com.itheima.health.common.MessageConst;
import com.itheima.health.entity.Result;
import com.itheima.health.pojo.Menu;
import com.itheima.health.service.MenuService;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author: liangWeiQUQ
 * @Description: 菜单权限功能的实现
 * @DateTime: 2021/3/11 14:38
 **/
@RestController
@RequestMapping("menu")
@Slf4j
public class MenuController {

    @DubboReference
    private MenuService menuService;

    /**
     * @Author: 传闻中的梁大侠
     * @Date: 9:19 2021/3/11
     * @Parms [username]
     * @ReturnType: com.itheima.health.entity.Result
     * @Description: 动态菜单-->根据用户名获取菜单权限集合
     */
    @GetMapping("getMenuList")
    public Result getMenuList(String username) {
        log.info("[username]:{}", username);
        List<Menu> menuList = menuService.getMenuList(username);
        log.info("[menuList]:{}", menuList);
        return new Result(true, MessageConst.ACTION_SUCCESS, menuList);
    }
}
